<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        //自己写有点难度

        //求一个数字数组当中最大值对应的索引
        var arr = [1,6,3,9]
        var max = 0;
        for (var i = 1; i < arr.length; i++){
            // 1 < 6 true
            // 然后把6的索引给max 然后继续比较
            if (arr[max] < arr[i]){
                max = i;
            }
        }
        console.log(max);
    </script>
</body>
</html>